﻿//        Another Demo from Andy L. & MissedMemo.com
// Borrow whatever code seems useful - just don't try to hold
// me responsible for any ill effects. My demos sometimes use
// licensed images which CANNOT legally be copied and reused.

using System;
using System.ComponentModel;
using System.Runtime.Serialization;

using MissedMemo.MeatAndCheeseDisc.UIHelperClasses;


namespace MissedMemo.MeatAndCheeseDisc.OrderMonitorService.OrderProcessing
{
    // Extend local service data proxy with Client-specific features...

    public partial class Pizza
    {
        public int NowServingNumber { get; set; }
        
        private bool _isCancelled;
        private OrderTimer _timer;

    #region Properties...

        public OrderTimer Timer
        {
            get { return _timer; }
        }

        public bool IsCancelled
        {
            get { return _isCancelled; }
            set
            {
                _isCancelled = value;

                if( _isCancelled )
                    Timer.SuspendTracking();

                RaisePropertyChanged( "IsCancelled" );
            }
        }

        // Simple bindable tests... (too trivial for ValueConverter?)

        public bool HasInstructions
        {
            get { return !string.IsNullOrEmpty( SpecialInstructions ); }
        }

        public bool HasOptions
        {
            get { return Options.Length > 0; }
        }

        public bool HasOptionsOrInstructions
        {
            get { return HasOptions || HasInstructions; }
        }

        public bool HasOptionsAndInstructions
        {
            get { return HasOptions && HasInstructions; }
        }

    #endregion (Properties)


        // Pizzas are not instantiated locally, but are DESERIALIZED from info. passed on the wire,
        // (so we can't extend the class inside a constructor, and must do it in the method below)
        
        [OnDeserializing]
        private void setDefaultValues( StreamingContext c )
        {
            _timer = new OrderTimer();
            Timer.BeginTracking();
        }
    }
}
